const { ListToNode, NodeToList, ListNode, timeL } = require("../utils.js");
/**
 * @param {number[]} nums
 * @param {number} target
 * @return {number[]}
 */
var searchRange = function (nums, target) {
  let arr = [];
  for (let i = 0; i < nums.length; i++) {
    if (nums[i] > target) return arr.length ? arr : [-1, -1];
    else if (nums[i] === target) {
      if (arr.length) arr[1] += 1;
      else arr = [i, i];
    }
  }
  return arr.length ? arr : [-1, -1];
};
let nums = [5, 7, 7, 8, 8, 10],
  target = 8;

timeL(searchRange, [nums, target]);
